using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class Pages_Admin_ConfirmProfile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        lblMessage.Text = "";
        if (gvProfile.Rows.Count == 0)
        {
            lblMessage.Text = "There is no accounts to confirm";
            return;
        }
        List<string> userNames = new List<string>();
        //Get selected UserNames
        foreach (GridViewRow row in gvProfile.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                CheckBox cbo = (CheckBox)row.Cells[0].FindControl("cboAgree");
                if (cbo != null)
                {
                    if (cbo.Checked)
                    {
                        string userName = row.Cells[0].Text;
                        userNames.Add(userName);
                    }
                }
            }
        }
        //Process confirmation:
        try
        {
            int result = DALAccount.ConfirmProfiles(userNames.ToArray());
            DALAccount.DeleteAccountsInQueue();
            lblMessage.Text = "Updated confirmed accounts";
            gvProfile.DataBind();
        }
        catch
        {
            lblMessage.Text = "Error updating confirmed accounts";
        }
    }
}
